<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>页面修改</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript">
	function myCheck() {
		// 获取form标签元素       
		var form = document.getElementById('form1');
		//获取form下元素下所有input标签      
		var inputArray = form.getElementsByTagName("input");
		var inputArrayLength = inputArray.length;
		console.log(inputArray + ",,")
		console.log(inputArrayLength + ",,")

		// 判断 select 中的 option 是否 选中 
		var obj = document.getElementById("select1"); //定位id
		var index = obj.selectedIndex; // 选中索引
		var text = obj.options[index].text; // 选中文本
		var value = obj.options[index].value; // 选中值
		if (value != "-1") {
			document.getElementById("msg2").innerHTML = "";

		}
		// 重新给 msg 赋值 
		document.getElementById("msg").innerHTML = "";
		//循环input元素数组    
		for (var int = 0; int < inputArrayLength; int++) {
			//判断每个input元素的值是否为空        
			if (inputArray[int].value == null || inputArray[int].value == '') {
				document.getElementById("msg").innerHTML = ('第' + (int + 1) + '个input的值为空.');
				return false;
			}
		}
		// select 的 值 的 是否 为空 
		if (value == "-1") {
			document.getElementById("msg2").innerHTML = "select  请选择 ";
			return false;
		}
		

		//如果所有Input标签的值都不为空的话       
		return true;
	}
</script>
</head>

<body>
	<div id="instrumentAlter">
		<h4>医疗器材 添加 页面</h4>
		<form class="form-horizontal" id="form1" action="addInstrument.do"
			method="post" onsubmit="return myCheck()">
			<div class="form-group">
				<label for="iname" class="col-sm-2 control-label">器械名</label><span
					id="msg"></span>
				<div class="col-sm-10">
					<input type="textarea" class="form-control" name="iname" id="iname"
						placeholder="清输入器械名">
				</div>
			</div>
			<div class="form-group">
				<label for="iprice" class="col-sm-2 control-label">价格</label>
				<div class="col-sm-10">
					<input type="test" class="form-control" name="iprice" id="iprice"
						placeholder="清输入价格">
				</div>
			</div>
			<div class="form-group">
				<label for="inum" class="col-sm-2 control-label">数量</label>
				<div class="col-sm-10">
					<input type="test" class="form-control" name="inum" id="inum"
						placeholder="清输入数量">
				</div>
			</div>
			<div class="form-group">
				<label for="type" class="col-sm-2 control-label">供货商</label>
				<div class="col-sm-10" id="type">
					<select name="supp.pid" class="form-control" id="select1">
						<option value="-1">请选择</option>
						<option value="1">遵义市意通医药有限责任公司</option>
						<option value="2">贵州鼎圣药业有限公司</option>
						<option value="3">铜仁梵天药业有限公司</option>
						<option value="4">国药控股贵州有限公司</option>
						<option value="5">广西梧州制药(集团)股份有限公司</option>
						<option value="6">飞利浦医疗</option>
						<option value="7">罗氏诊断</option>
						<option value="8">西门子</option>
						<option value="9">美敦力</option>
					</select><span id="msg2"></span>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-info">添加</button>
				</div>
			</div>
		</form>
	</div>
</body>
</html>